package com.ithinksflow.auth.security.utils;

import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * @Description
 * @ClassName HttpUtils
 * @Author MR.LI
 * @date 2020.11.29 21:55
 */
public class HttpUtils {

    /**
     * 获取HttpServletRequest
     * @return
     */
    public static HttpServletRequest getHttpServletRequest(){
        return ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
    }

    /**
     * 输出信息到浏览器
     */
    public static void write(HttpServletResponse httpServletResponse,Object object){
        httpServletResponse.setContentType("application/json;charset=utf-8");

    }
}
